export const isUsername = (username) => /^[^_^0-9][_a-zA-Z0-9]{4,18}$/.test(username)

export const isExternal = (path) => /^(https?:|mailto:|tel:)/.test(path)

export const isArray = (arg) => typeof Array.isArray === 'undefined' ? Object.prototype.toString.call(arg) === '[object Array]' : Array.isArray(arg)

export const isURL = (url) => /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/.test(url)

export const isMobile = (phone) => /^1[3|4|5|7|8|9][0-9]{9}$/.test(phone)

export const isTel = (tel) => /^0\d{2,3}-\d{7,8}$/.test(tel)

export const isMobileAndTel = (phone) => /^((0\d{2,3}-\d{7,8})|(1[3|4|5|7|8|9]\d{9}))$/.test(phone)

export const isEmail = (email) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email)

export const isQQ = (qq) => /^[1-9][0-9]{4,12}$/.test(qq)

export const isLowerCase = (str) => /^[a-z]+$/.test(str)

export const isUpperCase = (str) => /^[A-Z]+$/.test(str)

export const isAlphabets = (str) => /^[A-Za-z]+$/.test(str)

export const isString = (str) => typeof str === 'string' || str instanceof String
